package com.stox.client.ui.javafx.chartingy.widget.toolbar;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.HBox;

import com.stox.client.ui.javafx.chartingy.event.listener.ZoomMouseEventStrategy;
import com.stox.client.ui.javafx.chartingy.view.ChartingView;
import com.stox.client.ui.javafx.core.util.CSS;
import com.stox.client.ui.javafx.core.util.UI;
import com.stox.shared.i18n.MessageSource;

public class ZoomTools extends HBox {

	private final Button zoomInButton = UI.mediumPlusButton(MessageSource.get("Zoom.In"));
	private final Button zoomOutButton = UI.mediumMinusButton(MessageSource.get("Zoom.Out"));
	private final ToggleButton mouseZoomButton = UI.mediumMouseCursorButton(MessageSource.get("Mouse.Zoom"));
	private final Button resetButton = UI.mediumCrossButton(MessageSource.get("Reset.Zoom"));

	public ZoomTools(final ChartingView chartingView) {
		UI.style(this, CSS.chartingToolsContainer, CSS.zoomToolBar);
		getChildren().addAll(zoomInButton, zoomOutButton, chartingView.prepareMouseEventStrategyToggleButton(mouseZoomButton, new ZoomMouseEventStrategy()), resetButton);

		zoomInButton.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(final ActionEvent event) {
				chartingView.getZoom().in();
			}
		});
		zoomOutButton.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(final ActionEvent event) {
				chartingView.getZoom().out();
			}
		});
		resetButton.setOnAction(new EventHandler<ActionEvent>() {
			@Override
			public void handle(final ActionEvent event) {
				chartingView.getZoom().reset();
			}
		});

	}

}
